www.gusucode.com > VC++ douglas道格拉斯算法示例-源码程序 > VC++ douglas道格拉斯算法示例-源码程序/code/douglasDoc.cpp

    //Download by http://www.NewXing.com
// douglasDoc.cpp : implementation of the CDouglasDoc class
//

#include "stdafx.h"
#include "douglas.h"

#include "douglasDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDouglasDoc

IMPLEMENT_DYNCREATE(CDouglasDoc, CDocument)

BEGIN_MESSAGE_MAP(CDouglasDoc, CDocument)
	//{{AFX_MSG_MAP(CDouglasDoc)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDouglasDoc construction/destruction

CDouglasDoc::CDouglasDoc()
{
	// TODO: add one-time construction code here
	m_douglas=NULL;
	m_bIsLoaded = FALSE;
}

CDouglasDoc::~CDouglasDoc()
{
}

BOOL CDouglasDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CDouglasDoc serialization

void CDouglasDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CDouglasDoc diagnostics

#ifdef _DEBUG
void CDouglasDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CDouglasDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDouglasDoc commands

void CDouglasDoc::OnFileOpen() 
{
	// TODO: Add your command handler code here
	char sfileter[]="map files(*.txt)|*.txt|任何文件(*.*)|*.*";
	CFileDialog dlg(TRUE,"txt","*.txt",OFN_HIDEREADONLY,sfileter);
	CString FileName;
    if(dlg.DoModal()==IDOK)
	{
		FileName=dlg.GetPathName();
		
	}
    CString strExt = dlg.GetFileExt();
	if(m_douglas!=NULL)
	{
		delete m_douglas;
		m_douglas = NULL;
	}
	m_douglas = new CMyDouglas;
	if(m_douglas->ReadData(FileName))
	{
		m_bIsLoaded = TRUE;
		m_douglas->GetMapSize(m_MapSize);
		m_douglas->GetWindowOrg(m_WindowOrgX, m_WindowOrgY);		 
	}
	UpdateAllViews(NULL);
}